]>
Commit | Line | Data |
---|---|---|
1 | import Foundation | |
2 | import ReplayKit | |
3 | ||
4 | extension CVImageBuffer { | |
5 | ||
6 | private static let contextQueue = DispatchQueue(label: "com.example.contextQueue") | |
7 | static let sharedContext: CIContext = { | |
8 | return CIContext() | |
9 | }() | |
10 | ||
11 | var cgImage: CGImage? { | |
12 | var result: CGImage? | |
13 | CVImageBuffer.contextQueue.sync { | |
14 | let ciImage = CIImage(cvImageBuffer: self) | |
15 | let width = CVPixelBufferGetWidth(self) | |
16 | let height = CVPixelBufferGetHeight(self) | |
17 | result = CVImageBuffer.sharedContext.createCGImage(ciImage, from: CGRect(x: 0, y: 0, width: width, height: height)) | |
18 | } | |
19 | return result | |
20 | } | |
21 | } |